const path = require('path')
const express = require('express');
const bodyParser = require('body-parser');

const error = require('./controllers/error')
const app = express();


app.set('view engine', 'ejs');
app.set('views', 'views')

const adminRoutes = require('./routes/admin');
const shopRouter = require('./routes/shop')

//定义是否处理非标准请求;
 app.use(bodyParser.urlencoded({extended:false}));
 //处理静态文件的中间件
 app.use(express.static(path.join(__dirname,'public')))
//  只处理post请求
 app.use('/admin',adminRoutes);
 app.use(shopRouter);
  app.use(error.getError)
 
app.listen(3000);